import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';

class PPLoading {

    final BuildContext _context;
    
    PPLoading(this._context);

    bool isShow = false;
    
    ///打开loading
    void show({Function onClosed}) {
        if(!isShow) {
            isShow = true;
            showDialog(
                context: _context,
                builder: (context) {
                    return SpinKitFadingCircle(color: Colors.white);
                }
            ).then((value) {
                isShow = false;
                onClosed(value);
            });
        }
    }
    
    ///关闭loading
    void close() {
        if(isShow) {
            isShow = false;
            Navigator.of(_context).pop();
        }
    }
}
